---------------------------------------------------------------------------------------------------- -- Mob death ---------------------------------------------------------------------------------------------------- -- Разработчик: Andrey Fidrya (Zmey) af@svitonline.com ---------------------------------------------------------------------------------------------------- class "mob_death" function mob_death:__init(obj, storage) self.object = obj self.st = storage end function mob_death:death_callback(victim, who) if who ~= nil then printf("mob_death: [%s] killed by [%s]", victim:name(), who:name()) local death = db.storage[victim:id()].death if not death then death = {} db.storage[victim:id()].death = death end death.killer = who:id() death.killer_name = who:name() else printf("mob_death: [%s] killed by [Unknown]", victim:name()) death.killer = -1 death.killer_name = nil end if xr_logic.try_switch_to_another_section(victim, self.st, db.actor) then return end end --------------------------------------------------------------------------------------------------------------------- function setup_generic_scheme(npc,ini,scheme,section,stype,temp) local death_section = ini:r_string_ex(section,"on_death") if (death_section) then local st = xr_logic.assign_storage_and_bind(npc,ini,"mob_death",death_section,temp) st.logic = xr_logic.cfg_get_switch_conditions(ini, death_section, npc) end end function add_to_binder(npc,ini,scheme,section,st,temp) st.action = mob_death(npc,st) xr_logic.subscribe_action_for_events(npc,st,st.action) end